<template>
	<view class="content">
		<view class="title">
			子组件B
		</view>
		<view class = "b-box">
			CompA组件传进来的值：
			<text class="intent-text-box">{{result}}</text>
		</view>
		<view class="b-box" style="margin: 10rpx;">
			<text>回传值：</text>
			<input type="text" v-model="callbackValue" style="color: yellow;"/>
			<button @click="sendOutside()" size="mini">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		name:"compB",
		data() {
			return {
				result:'',
				callbackValue:''
			}
		},
		created(){
			uni.$on('getIntent',(msg) =>{
				console.error("---CompB---getIntent----->" + msg);
				this.result = msg;
			});
		},
		methods:{
			sendOutside(){
				console.warn("---CompB---sendOutside----->" + this.callbackValue);
				this.$emit('callBackFun',this.callbackValue);
			}
		}
	}
</script>

<style>
.content {
  margin: 20rpx;
}
.title {
  font-size: 50rpx;
  margin-bottom: 20rpx;
}
.b-box {
  margin: 10rpx 0;
}
.intent-text-box {
  font-weight: bold;
  color: red;
}
</style>